package com.atguigu.oss.util;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 常量类，读取配置文件application.properties中的配置
 */
@Component
//@PropertySource("classpath:application.properties")
public class ConstantPropertiesUtil implements InitializingBean {
    @Value("${qiniu.oss.file.ossUrl}")
    private String ossUrl;
    @Value("${qiniu.oss.file.accessKey}")
    private String accessKey;
    @Value("${qiniu.oss.file.secretKey}")
    private String secretKey;
    @Value("${qiniu.oss.file.bucketName}")
    private String bucketName;

    public static String OSS_URL;
    public static String ACCESS_KEY;
    public static String SECRET_KEY;
    public static String BUCKET_NAME;
    @Override
    public void afterPropertiesSet() throws Exception {
        OSS_URL = ossUrl;
        ACCESS_KEY = accessKey;
        SECRET_KEY = secretKey;
        BUCKET_NAME = bucketName;
    }
}

